﻿using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using HengTong.Model.Attributes;
using HengTong.Model.Interfaces;
using TiaoTaoHelper.Wtm.Models;
using WalkingTec.Mvvm.Core;

namespace HengTong.Model.Db.Hr;

/// <summary>
/// 员工档案实体类
/// </summary>
[Display(Name = "人员档案", Description = "人员档案", GroupName = "实体单据")]
public class SysPerson : BasePoco, IDataPrivilegeEntity
{
    [Required]
    [Display(Name = "姓名", Description = "员工姓名", GroupName = "基本信息")]
    [StringLength(128)]
    public string Name { get; set; }

    [Display(Name = "工号", Description = "员工工号", GroupName = "基本信息")]
    [StringLength(128)]
    public string StaffNo { get; set; }

    [Required]
    [Display(Name = "出生日期", Description = "出生日期", GroupName = "基本信息")]
    public DateTime? BirthDate { get; set; }

    [Display(Name = "年龄", Description = "员工年龄", GroupName = "基本信息")]
    public int? Age { get; set; }

    [Required]
    [Display(Name = "性别", Description = "性别", GroupName = "基本信息")]
    public Gender? Gender { get; set; }

    [Display(Name = "民族", Description = "民族", GroupName = "基本信息")]
    public Ethnicity? Ethnicity { get; set; }

    [Display(Name = "最高学历", Description = "最高学历", GroupName = "基本信息")]
    public EducationLevel? HighestEducation { get; set; }

    [Display(Name = "婚姻状况", Description = "婚姻状况", GroupName = "基本信息")]
    public MaritalStatus? MaritalStatus { get; set; }

    [Display(Name = "照片", Description = "员工照片文件", GroupName = "基本信息")]
    public Guid? PhotoId { get; set; }

    [Display(Name = "照片", Description = "员工照片文件", GroupName = "基本信息")]
    public FileAttachment Photo { get; set; }

    // 在 SysPerson 类中增加退伍军人相关字段
    [Display(Name = "是否退伍军人", Description = "是否为退伍军人", GroupName = "基本信息")]
    public bool? IsVeteran { get; set; }

    [Display(Name = "退伍证书", Description = "退伍证书文件", GroupName = "基本信息")]
    public Guid? VeteranCertificateId { get; set; }

    [Display(Name = "退伍证书", Description = "退伍证书文件", GroupName = "基本信息")]
    public FileAttachment VeteranCertificate { get; set; }

    // 身份信息
    [Required]
    [Display(Name = "身份证号", Description = "身份证号码", GroupName = "身份信息")]
    [StringLength(18)]
    [IdCardValidation]
    public string IdCardNo { get; set; }

    [Display(Name = "身份证正面照片", Description = "身份证正面照片文件", GroupName = "身份信息")]
    public Guid? IdCardFrontPhotoId { get; set; }

    [Display(Name = "身份证正面照片", Description = "身份证正面照片文件", GroupName = "身份信息")]
    public FileAttachment IdCardFrontPhoto { get; set; }

    [Display(Name = "身份证反面照片", Description = "身份证反面照片文件", GroupName = "身份信息")]
    public Guid? IdCardBackPhotoId { get; set; }

    [Display(Name = "身份证反面照片", Description = "身份证反面照片文件", GroupName = "身份信息")]
    public FileAttachment IdCardBackPhoto { get; set; }

    [Display(Name = "身份证有效期", Description = "身份证有效期至", GroupName = "身份信息")]
    public DateTime? IdCardExpiryDate { get; set; }

    // 户籍信息
    [Display(Name = "户口所在地", Description = "户口所在地", GroupName = "户籍信息")]
    [StringLength(128)]
    public string HouseholdRegistration { get; set; }

    [Display(Name = "籍贯", Description = "籍贯", GroupName = "户籍信息")]
    [StringLength(128)]
    public string NativePlace { get; set; }

    // 政治面貌
    [Display(Name = "政治面貌", Description = "政治面貌", GroupName = "政治面貌")]
    public PoliticalStatus? PoliticalStatus { get; set; }

    [Display(Name = "入党(团)日期", Description = "入党或入团日期", GroupName = "政治面貌")]
    public DateTime? PartyJoinDate { get; set; }

    [Display(Name = "入党所在支部", Description = "入党所在支部", GroupName = "政治面貌")]
    [StringLength(128)]
    public string PartyBranch { get; set; }

    [Display(Name = "档案所在地", Description = "档案存放地", GroupName = "政治面貌")]
    [StringLength(128)]
    public string ArchiveLocation { get; set; }

    [Display(Name = "存档号", Description = "档案编号", GroupName = "政治面貌")]
    [StringLength(128)]
    public string ArchiveNo { get; set; }

    [Display(Name = "档案调出日期", Description = "档案调出日期", GroupName = "政治面貌")]
    public DateTime? ArchiveTransferOutDate { get; set; }

    [Display(Name = "档案调入日期", Description = "档案调入日期", GroupName = "政治面貌")]
    public DateTime? ArchiveTransferInDate { get; set; }

    // 联系方式
    [Display(Name = "家庭住址", Description = "家庭住址", GroupName = "联系方式")]
    [StringLength(128)]
    public string HomeAddress { get; set; }

    [Display(Name = "手机号", Description = "手机号码", GroupName = "联系方式")]
    [StringLength(11)]
    public string Phone { get; set; }

    [Display(Name = "邮箱", Description = "电子邮箱", GroupName = "联系方式")]
    [StringLength(128)]
    public string Email { get; set; }

    // 银行账户
    [Display(Name = "工资卡银行", Description = "工资卡开户银行", GroupName = "银行账户")]
    [StringLength(128)]
    public string SalaryBank { get; set; }

    [Display(Name = "工资卡号", Description = "工资卡账号", GroupName = "银行账户")]
    [StringLength(128)]
    public string SalaryAccount { get; set; }

    [Display(Name = "奖金卡银行", Description = "奖金卡开户银行", GroupName = "银行账户")]
    [StringLength(128)]
    public string BonusBank { get; set; }

    [Display(Name = "奖金卡号", Description = "奖金卡账号", GroupName = "银行账户")]
    [StringLength(128)]
    public string BonusAccount { get; set; }

    // 工作信息
    [Display(Name = "人事组织", Description = "关联的人事组织", GroupName = "工作信息")]
    public SysOrg Org { get; set; }

    [Display(Name = "人事组织ID", Description = "关联的人事组织ID", GroupName = "工作信息")]
    public Guid? OrgId { get; set; }

    [Display(Name = "所属部门", Description = "关联的部门", GroupName = "工作信息")]
    public SysGroup Group { get; set; }

    [Display(Name = "所属部门ID", Description = "关联的部门ID", GroupName = "工作信息")]
    public Guid? GroupId { get; set; }

    [Display(Name = "工作岗位", Description = "关联的工作岗位", GroupName = "工作信息")]
    public SysJobPosition JobPosition { get; set; }

    [Display(Name = "工作岗位ID", Description = "关联的工作岗位ID", GroupName = "工作信息")]
    public Guid? JobPositionId { get; set; }

    [Display(Name = "简历", Description = "员工简历文件", GroupName = "工作信息")]
    public Guid? ResumeId { get; set; }

    [Display(Name = "简历", Description = "员工简历文件", GroupName = "工作信息")]
    public FileAttachment Resume { get; set; }

    [Display(Name = "入职日期", Description = "入职日期", GroupName = "工作信息")]
    public DateTime? HireDate { get; set; }

    [Display(Name = "转正日期", Description = "转正日期", GroupName = "工作信息")]
    public DateTime? ConfirmationDate { get; set; }

    [Display(Name = "用工形式", Description = "用工形式", GroupName = "工作信息")]
    public EmploymentType? EmploymentType { get; set; }

    [Display(Name = "劳动合同类型", Description = "劳动合同类型", GroupName = "工作信息")]
    public ContractType? ContractType { get; set; }

    [Display(Name = "合同编号", Description = "合同编号", GroupName = "工作信息")]
    [StringLength(64)]
    public string ContractNo { get; set; }

    [Display(Name = "合同起始日", Description = "劳动合同起始日", GroupName = "工作信息")]
    public DateTime? ContractStartDate { get; set; }

    [Display(Name = "合同终止日", Description = "劳动合同终止日", GroupName = "工作信息")]
    public DateTime? ContractEndDate { get; set; }

    [Display(Name = "离职日期", Description = "离职日期", GroupName = "工作信息")]
    public DateTime? ResignationDate { get; set; }

    [Display(Name = "离职原因", Description = "离职原因", GroupName = "工作信息")]
    [StringLength(128)]
    public string ResignationReason { get; set; }

    [Display(Name = "离职类型", Description = "离职类型", GroupName = "工作信息")]
    public ResignationType? ResignationType { get; set; }

    [Display(Name = "人员状态", Description = "人员状态", GroupName = "工作信息")]
    public PersonState? State { get; set; } = PersonState.在职;

    [Display(Name = "参加工作时间", Description = "首次参加工作时间", GroupName = "工作信息")]
    public DateTime? JoinWorkDate { get; set; }

    [Display(Name = "档案年龄", Description = "档案年龄的日期格式", GroupName = "工作信息")]
    public DateTime? ArchiveAgeDate { get; set; }

    [Display(Name = "工龄", Description = "工龄（年）", GroupName = "工作信息")]
    [Column(TypeName = "decimal(10,1)")]
    public decimal? WorkYears { get; set; }

    [Display(Name = "司龄", Description = "在本公司工作的年限（年）", GroupName = "工作信息")]
    [Column(TypeName = "decimal(10,1)")]
    public decimal? CompanyYears { get; set; }

    [Display(Name = "生育状况", Description = "生育状况", GroupName = "基本信息")]
    public FertilityStatus? FertilityStatus { get; set; }

    [Display(Name = "专业大类", Description = "专业大类", GroupName = "基本信息")]
    public MajorCategory? MajorCategory { get; set; }

    [Display(Name = "专业名称", Description = "所学专业名称", GroupName = "基本信息")]
    [StringLength(128)]
    public string MajorName { get; set; }

    [Display(Name = "是否存在亲属关系", Description = "是否和本单位存在亲属关系", GroupName = "基本信息")]
    public bool? HasRelativeInCompany { get; set; }

    [Display(Name = "亲属姓名", Description = "本单位亲属姓名", GroupName = "基本信息")]
    [StringLength(64)]
    public string RelativeName { get; set; }

    [Display(Name = "亲属关系", Description = "与本单位亲属的关系", GroupName = "基本信息")]
    public RelationshipType? RelationshipType { get; set; }

    [Display(Name = "身高(cm)", Description = "身高（厘米）", GroupName = "基本信息")]
    [Column(TypeName = "decimal(5,2)")]
    public decimal? Height { get; set; }

    [Display(Name = "体重(kg)", Description = "体重（公斤）", GroupName = "基本信息")]
    [Column(TypeName = "decimal(5,2)")]
    public decimal? Weight { get; set; }


    // 其他
    [Display(Name = "血型", Description = "血型", GroupName = "其他")]
    public BloodType? BloodType { get; set; }

    [Display(Name = "兴趣爱好特长", Description = "兴趣爱好及特长", GroupName = "其他")]
    [StringLength(128)]
    public string Hobbies { get; set; }

    [Display(Name = "排序", Description = "排序字段", GroupName = "其他")]
    [Column(TypeName = "decimal(10,2)")]
    public decimal? Order { get; set; } = 0;

    [Display(Name = "学习经历")] public virtual ICollection<SysPersonEducation> PersonEducations { get; set; }
    [Display(Name = "家庭成员")] public virtual ICollection<SysPersonFamily> PersonFamilies { get; set; }
    [Display(Name = "工作经历")] public virtual ICollection<SysPersonWork> PersonWorks { get; set; }

    [Display(Name = "培训考试")] public virtual ICollection<SysPersonTrainExam> PersonTrainExams { get; set; }

    [Display(Name = "员工体检")] public virtual ICollection<SysPersonMedical> PersonMedicals { get; set; }

    [Display(Name = "员工履历")] public virtual ICollection<SysPersonResume> PersonResumes { get; set; }

    [Display(Name = "员工合同")] public virtual ICollection<SysPersonContract> PersonContracts { get; set; }

    [Display(Name = "荣誉职称")]
    public virtual ICollection<SysPersonProfessionalTitle> PersonProfessionalTitles { get; set; }

    [Display(Name = "社保信息")] public virtual ICollection<SysPersonSocialSecurity> PersonSocialSecurities { get; set; }
}